﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LP580.CG;

public partial class Manage_CG_UserCompanyInfoOperate : System.Web.UI.Page
{
    private string act = Utils.RQ_str("act").ToLower();
    private int id = Utils.RQ_int("id");
    protected void Page_Load(object sender, EventArgs e)
    {
        bindContrl();
        if (!this.IsPostBack)
            bindData();
    }

    private void bindContrl()
    {
    }

    private void bindData()
    {
        if (act == "edit")
        {
            ltMgTitle.Text = "修改企业信息";
            ltPathTitle.Text = "[修改企业信息]";
            ltOperTitle.Text = "修改企业信息";
            clsUserCompanyInfo cls = new clsUserCompanyInfo(id);
            tbxUserName.Text = cls.UserName;
            tbxUserName.ReadOnly = true;
            tbxCompanyName.Text = cls.CompanyName;
            tbxBuildYear.Text = cls.BuildYear;
            tbxContactPerson.Text = cls.ContactPerson;
            tbxTel.Text = cls.Tel;
            tbxDeptName.Text = cls.DeptName;
            tbxUserPosition.Text = cls.UserPosition;
            tbxFax.Text = cls.Fax;
            tbxMobile.Text = cls.Mobile;
            tbxEmail.Text = cls.Email;
            tbxWebsite.Text = cls.Website;
            tbxCompanyAddress.Text = cls.CompanyAddress;
            tbxCompanyType.Text = cls.CompanyType;
            tbxRegisteredCapital.Text = cls.RegisteredCapital;
            tbxSalesType.Text = cls.SalesType;
            tbxCompanyShortName.Text = cls.CompanyShortName;
            btnSave.Text = " 修 改 ";

            lkUser.Visible = true;
            lkUser.NavigateUrl = "../User/UserAccountOperate.aspx?act=edit&id=" + id;
            lkLoginWithThis.Visible = true;
            lkLoginWithThis.NavigateUrl = "../User/UserUtils.aspx?act=login&id=" + id;
        }
        else
        {
            ltMgTitle.Text = "添加企业信息";
            ltPathTitle.Text = "[添加企业信息]";
            ltOperTitle.Text = "添加企业信息";
        }
    }

    protected void btnSave_Click(object sender, EventArgs e)
    {
        string name = tbxUserName.Text.Trim();
        if (name == "")
        {
            Utils.WrAlertGoBack("标注*号为必填不可为空！");
        }
        clsUserCompanyInfo cls = new clsUserCompanyInfo(id);
        cls.UserName = name;
        cls.CompanyName = tbxCompanyName.Text.Trim();
        cls.BuildYear = tbxBuildYear.Text.Trim();
        cls.ContactPerson = tbxContactPerson.Text.Trim();
        cls.Tel = tbxTel.Text.Trim();
        cls.DeptName = tbxDeptName.Text.Trim();
        cls.UserPosition = tbxUserPosition.Text.Trim();
        cls.Fax = tbxFax.Text.Trim();
        cls.Mobile = tbxMobile.Text.Trim();
        cls.Email = tbxEmail.Text.Trim();
        cls.Website = tbxWebsite.Text.Trim();
        cls.CompanyAddress = tbxCompanyAddress.Text.Trim();
        cls.CompanyType = tbxCompanyType.Text.Trim();
        cls.RegisteredCapital = tbxRegisteredCapital.Text.Trim();
        cls.SalesType = tbxSalesType.Text.Trim();
        cls.CompanyShortName = tbxCompanyShortName.Text.Trim();
        if (act.ToLower() == "edit")
        {
            clsUserCompanyInfo.Update(cls);
        }
        else
        {
            clsUserCompanyInfo.Insert(cls);
        }
        Response.Redirect("UserCompanyInfoList.aspx", true);
    }
}